//
//  DownloadChinaHandle.m
//  GoodBuy
//
//  Created by dlios on 15-5-14.
//  Copyright (c) 2015年 GoodBuy. All rights reserved.
//

#import "DownloadChinaHandle.h"
#import "AFNetworking.h"
@implementation DownloadChinaHandle
+ (instancetype)shareChinaHandle
{
    static DownloadChinaHandle *dataHandle = nil;
    if (dataHandle == nil) {
        
        dataHandle = [[DownloadChinaHandle alloc] init];
        [dataHandle initChinaData];
    }
    return dataHandle;
}
- (void)initChinaData
{
    NSString *url_string = [NSString stringWithFormat:@"http://api.smzdm.com/v1/youhui/articles?limit=20"];
    
    
    //[NSSet setWithObjects:@"text/plain",@"text/json",@"application/json",@"text/javascript",@"text/html",nil];  代表支持所有的接口类型
    
    AFHTTPRequestOperationManager* manager = [AFHTTPRequestOperationManager manager];
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/plain",@"text/json",@"application/json",@"text/javascript",@"text/html",nil];
    [manager GET:url_string parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
//        [netWorkManager stopMonitoring];
        
//        NSLog(@"使用AFN进行get请求 ===  %@",responseObject);
        NSDictionary *dic1 = [[NSDictionary alloc]init];
        dic1 = responseObject;
        NSMutableArray *arr = [[NSMutableArray alloc]init];
        arr = [dic1 objectForKey:@"data"];
        
        self.ArrChina = [[NSMutableArray alloc]init];
        for (NSDictionary *dic in arr) {
            YBChinaList *China = [[YBChinaList alloc]init];
            [China setValuesForKeysWithDictionary:dic];
            [_ArrChina addObject:China];
           
        }
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        NSLog(@"失败==== %@",error);
        
    }];
}
@end
